package com.atguigu.boot.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @ClassName RedisController
 * @Description 此类描述:
 * @Author dangchen
 * @DateTime 2022-09-15 11:50
 * @Version 1.0
 */
@RestController
@Slf4j
@RequestMapping("/redis")
public class RedisController {
    @Resource
    private RedisTemplate redisTemplate;

    @PostMapping("/add")
    public void add(){
        redisTemplate.opsForValue().set("nihao","shangguigu");
    }

    @GetMapping("/{key}")
    public String getById(@PathVariable String key){
        return (String) redisTemplate.opsForValue().get(key);
    }
}
